package com.xmall.exceptionHandler;

import com.xmall.bean.vo.BaseRespVo;
import org.apache.shiro.authc.IncorrectCredentialsException;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class CustomExceptionHandler {

    @ExceptionHandler(IncorrectCredentialsException.class)
    public BaseRespVo incorrectCredentialsExceptionHandler(IncorrectCredentialsException exception) {
        String message = exception.getMessage();
        return BaseRespVo.fail(message);
    }

    @ExceptionHandler(HttpMessageNotReadableException.class)
    public BaseRespVo HttpMessageNotReadableException(HttpMessageNotReadableException exception) {
        String message = exception.getMessage();
        return BaseRespVo.fail(message, 505);
    }
}
